import request from "@/api/request";
import { ADD_DYNAMIC_API } from "@/api/api_constant";

export const addDynamic = async (dynamic) => {
  const formData = new FormData();
  formData.append("dynamic_date", Date.now());
  formData.append("dynamic_user_avatar", dynamic.dynamic_user_avatar);
  formData.append("dynamic_creator_id", dynamic.dynamic_creator_id);
  formData.append("dynamic_content", dynamic.dynamic_content);
  formData.append("dynamic_creator_name", dynamic.dynamic_creator_name);
  for (var i = 0; i < dynamic.dynamic_imgs.length; i++) {
    formData.append("dynamic_imgs", dynamic.dynamic_imgs[i].file);
  }
  return await request.post(ADD_DYNAMIC_API, formData);
};
